from __future__ import unicode_literals
from datetime import datetime
from django.db import models
from users.models import UserProfile
from operation.models import LabelProfile
# Create your models here.


class TopicProfile(models.Model):
    userprofile_id = models.ForeignKey(UserProfile,verbose_name='用户信息',on_delete=models.CASCADE)
    topic_title = models.CharField("话题标题", max_length=50)
    topic_content = models.TextField('话题内容')
    topic_label = models.ManyToManyField(LabelProfile)
    published_time = models.DateTimeField("发布时间", default=datetime.now)
    topic_collected_num = models.IntegerField("收藏次数", default=0)
    topic_reading_quantity = models.IntegerField("阅读量",default=0)
    topic_shared_num = models.IntegerField("分享次数", default=0)
    topic_agreed_num = models.IntegerField("点赞次数", default=0)
    topic_opposed_num = models.IntegerField("反对数量", default=0)
    topic_commented_num = models.IntegerField("评论数量", default=0)
    topic_informed_num = models.IntegerField("举报次数", default=0)

    class Meta:
        verbose_name = "话题"
        verbose_name_plural = verbose_name


class topic_comment_profile(models.Model):
    userprofile_id = models.ForeignKey(UserProfile, verbose_name='用户信息', on_delete=models.CASCADE)
    topic_id = models.ForeignKey(TopicProfile, verbose_name='话题', on_delete=models.CASCADE)
    topic_comment_content = models.CharField('评论内容',max_length=200)
    topic_comment_comment_num = models.IntegerField("评论数量", default=0)
    topic_comment_agreed_num = models.IntegerField("点赞次数", default=0)
    topic_comment_opposed_num = models.IntegerField("举报次数", default=0)
    topic_comment_published_time = models.DateTimeField("发表时间", default=datetime.now)
    topic_comment_collected_num = models.IntegerField("收藏次数", default=0)
    topic_comment_shared_num = models.IntegerField("分享次数", default=0)

    class Meta:
        verbose_name = '话题评论'
        verbose_name_plural = verbose_name



class topic_respect_profile(models.Model):
    userprofile_id = models.ForeignKey(UserProfile, related_name="topic_comment", verbose_name='用户信息', on_delete=models.CASCADE)
    comment_userprofile_id = models.ForeignKey(UserProfile, related_name="topic_respect", verbose_name='评论对象', null=True, on_delete=models.CASCADE)
    topic_respect_profile_id = models.ForeignKey(topic_comment_profile, verbose_name='话题评论', on_delete=models.CASCADE)
    topic_respect_content = models.CharField('回复内容',max_length=200)
    topic_respect_agreed_num = models.IntegerField("点赞次数", default=0)
    topic_respect_informed_num = models.IntegerField("举报次数", default=0)
    topic_respect_published_time = models.DateTimeField("发表时间", default=datetime.now)

    class Meta:
        verbose_name = '话题评论的回复'
        verbose_name_plural = verbose_name